﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace Weazel.Badger.Vhdl
{
  public class VariableDeclaration : IProcessDeclarativeItem
  {
    private string name;
    private string type;
    private string initialValue;

    public VariableDeclaration(string name, string type)
    {
      this.name = name;
      this.type = type;
    }

    public VariableDeclaration(string name, string type, string initialValue)
    {
      this.name = name;
      this.type = type;
      this.initialValue = initialValue;
    }

    public void Write(System.CodeDom.Compiler.IndentedTextWriter writer)
    {

      string result = null;

      if (initialValue == null)
      {
        result = string.Format(
            "variable {0} : {1};",
            name,
            type
          );
      }
      else
      {
        result = string.Format(
            "variable {0} : {1} := {2};",
            name,
            type,
            initialValue
          );
      }

      writer.WriteLine(result);
    }
  }
}
